#pragma once

#include <iostream>
#include <string>
#include <list>
#include <sstream>
#include <time.h>

using namespace std;

#define INVALID_FILENAME_CHAR_CONUT 41

static wchar_t invalidFileNameChars[INVALID_FILENAME_CHAR_CONUT] =  {
		'"', '<', '>', '|', '\0', '\x0001', '\x0002', '\x0003', '\x0004', '\x0005', '\x0006', '\a', '\b', '\t', '\n', '\v', 
		'\f', '\r', '\x000e', '\x000f', '\x0010', '\x0011', '\x0012', '\x0013', '\x0014', '\x0015', '\x0016', '\x0017', '\x0018', '\x0019', '\x001a', '\x001b', 
		'\x001c', '\x001d', '\x001e', '\x001f', ':', '*', '?', '\\', '/'};


class FilerFrogUtils
{
public:	
	// System
	static bool IsVistaOs();

	// Files Systems
	static wstring GetFileDirectoyPath(const wstring& filePath);
	static wstring GetFileNameFromPath(const wstring& filePath);
	static void MakeListInDir(const wstring& dir, list<wstring>& retVal);

	static wstring GetFileNameWithoutExtension(const wstring& filePath);
	static wstring GetFileNameExtension(const wstring& filePath);

	static wstring GetSeceretFilePath();
	static wstring GetFrogAppDataPath();

	// Clipboard
	static bool CopyStringToClipboard(const wstring& str);

	// GUI
	static void SwapItems(HWND hWndList,int nSourceIndex,int nDestIndex);
	static HICON GetExtensionSmallIcon(const wstring& fileExt);
	static void SetTopMost(HWND hWnd, const BOOL TopMost);

	static bool IsDirectory(const wstring& filePath);
	static bool IsDirectoryInRoot(const wstring& filePath);

	template <class T> static bool FromString(T& t, const wstring& s, std::ios_base& (*f)(std::ios_base&))
	{
		std::wistringstream iss(s);
		return !(iss >> f >> t).fail();
	}

	static bool IsFileNameValid(const wstring& fileName);
	static bool IsFileNameReplaceStringValid(const wstring& find);

	static wstring ToLower(const wstring& str);

	static int GetPassedDaysFromLastSavedDay();
	static void SetTodayAsLastSavedDate();

	static wstring GetDesktopDirectory();
	static wstring GetDesktopAllDirectory();
private:
	static bool IsCharInInvalidFileNameChar(wchar_t c);

	static int GetPassedDays(time_t startDate, time_t endDate);
	static int GetPassedDaysFromToday(time_t startDate);
	static time_t GetLastSavedDate();
};
